﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Data.ConnectionUI;

namespace SolutionGenerator
{
    public partial class WizardGetConnectionString : UserControlParent
    {
        public WizardGetConnectionString(SolutionConfiguration configuration) : base(configuration)
        {
            InitializeComponent();
        }
        private void SolutionGeneratorGetConnectionInputDialogButton_Click(object sender, EventArgs e)
        {
            DataSource sqlDataSource = new DataSource("MicrosoftSqlServer", "Microsoft SQL Server");
            sqlDataSource.Providers.Add(DataProvider.OleDBDataProvider);
            DataConnectionDialog dlg = new DataConnectionDialog();
            dlg.DataSources.Add(sqlDataSource);
            if (DataConnectionDialog.Show(dlg) == System.Windows.Forms.DialogResult.OK)
                SolutionGeneratorInputConnectionInfo.Text = dlg.ConnectionString;
        }
        public override bool IsPageValid
        {
            get { return SolutionGeneratorInputConnectionInfo.Text.Trim().Length > 0; }
        }
        public override string ValidationMessage
        {
            get { return TextMessage.WizardValidation_GetConnectionInfo; }
        }
        public override void LoadWizard()
        {
            SolutionGeneratorInputConnectionInfo.Text = GetSolutionConfiguration.ConnectionString;
        }
        public override void Save()
        {
            GetSolutionConfiguration.ConnectionString = SolutionGeneratorInputConnectionInfo.Text;
        }
        public override string WizardTitle
        {
            get
            {
                return TextMessage.WizardTitle_GetConnectionInfo;
            }
        }
    }
}